package com.jingtai.shop.webfacade.bo.shopcar;


import com.jingtai.common.webfacade.BaseBO;
import com.jingtai.common.webfacade.error.CommonException;
import com.jingtai.common.webfacade.error.ErrorEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

/**
 * 购物车列表删除逻辑传参
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SkuBO extends BaseBO {

    /**
     * sku 编码数组
     */
    private String skuCode;

    /**
     * 0详情  1购物车
     */
    private String type;

    /**
     * 0详情  1购物车
     */
    private Long goodsId;

    /**
     * 购买个数
     */
    private Integer quantity;

    @Override
    public void validate() {
        super.validate();

        if (StringUtils.isBlank(skuCode) || StringUtils.isBlank(type)) {
            throw new CommonException(ErrorEnum.REQUIRED_PARAM_EMPTY);
        }

        if(type.equals("0")){
            if (StringUtils.isBlank(goodsId.toString()) || StringUtils.isBlank(quantity.toString())) {
                throw new CommonException(ErrorEnum.REQUIRED_PARAM_EMPTY);
            }
        }
    }
}
